package com.neusoft.hifly.information.article.entity;

import java.io.Serializable;
import java.time.LocalDateTime;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;

import com.neusoft.hifly.commons.lang.LocalDateUtil;
import com.neusoft.hifly.core.utils.GlobalConstants;

/**
 * Title: 文章资讯服务
 * <p>
 * Description: 文章审核日志对象
 * <p>
 * Copyright: 2019
 * <p>
 * Company: 东软汉枫
 *
 * @author lh_neu
 * @version 1.0.0
 */
@JsonIgnoreProperties(ignoreUnknown = true)
@TableName(value = GlobalConstants.DYNAMIC_TABLE_NAME_PREFIX + "_INFO_ARTICLE_LOG")
public class ArticleLogObj implements Serializable {
	public static final String STEP_ADD = "起草";
	public static final String STEP_EDIT = "编辑";
	public static final String STEP_PROOF = "校对";
	public static final String STEP_APPROVE = "审核";
	public static final String STEP_RELEASE = "发布";
	public static final String STEP_CANCEL = "取消发布";
	public static final String STEP_DEL = "删除";
	public static final String STEP_REJECT = "驳回";

	private static final long serialVersionUID = -159183567806561L;
	// 主键
	@TableId(value = "ID")
	private long id;
	// 逻辑主键
	@TableField(value = "LOGIC_ID")
	private long logicId;
	// 租户逻辑ID
	@TableField(value = "ORGAN_LOGIC_ID")
	private long organLogicId;
	// 文章ID
	@TableField(value = "ARTICLE_ID")
	private long articleId;
	// 操作步骤（起草/校对/审核/发布等）
	@TableField(value = "OPERATOR_STEP")
	private String operatorStep;
	// 操作人
	@TableField(value = "OPERATOR_ID")
	private long operatorId;
	// 操作人名称
	@TableField(value = "OPERATOR_NAME")
	private String operatorName;
	// 操作时间
	@TableField(value = "OPERATOR_TIME")
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@JsonDeserialize(using = LocalDateTimeDeserializer.class)
	@JsonSerialize(using = LocalDateTimeSerializer.class)
	private LocalDateTime operatorTime;
	// 意见
	@TableField(value = "OPERATOR_CONTENT")
	private String operatorContent;
	// EXT1
	@TableField(value = "EXT1")
	private String ext1;
	// EXT2
	@TableField(value = "EXT2")
	private String ext2;
	// EXT3
	@TableField(value = "EXT3")
	private String ext3;
	// EXT4
	@TableField(value = "EXT4")
	private String ext4;
	// EXT5
	@TableField(value = "EXT5")
	private String ext5;

	// ################### 临时数据 ####################

	// 格式化后的字符串日期
	@TableField(exist = false)
	private String operatorTimeStr;
	// 租户编码
	@TableField(exist = false)
	private String organCode;

	/**
	 * 构造方法
	 */
	public ArticleLogObj() {
	}

	/**
	 * 构造方法
	 *
	 * @param articleId
	 *            文章ID
	 * @param operatorStep
	 *            操作步骤
	 * @param operatorContent
	 *            意见
	 */
	public ArticleLogObj(final long articleId, final String operatorStep, final String operatorContent) {
		super();
		this.articleId = articleId;
		this.operatorStep = operatorStep;
		this.operatorContent = operatorContent;
	}

	/**
	 * 构造方法
	 *
	 * @param articleId
	 *            文章ID
	 * @param operatorStep
	 *            操作步骤
	 */
	public ArticleLogObj(final long articleId, final String operatorStep) {
		super();
		this.articleId = articleId;
		this.operatorStep = operatorStep;
	}

	/**
	 * 得到对象的哈希值
	 *
	 * @return int 对象的哈希值
	 */
	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(this.getLogicId()).toHashCode();
	}

	/**
	 * 比较两个对象是否相等
	 *
	 * @param other
	 *            要比较的对象
	 * @return boolean 相同返回true，否则返回flase
	 */
	@Override
	public boolean equals(final Object other) {
		if (!(other instanceof ArticleLogObj)) {
			return false;
		}
		final ArticleLogObj castOther = (ArticleLogObj) other;
		return new EqualsBuilder().append(this.getLogicId(), castOther.getLogicId()).isEquals();
	}

	/**
	 * 返回对象的字符串值
	 *
	 * @return String 表示用户对象的字符串值
	 */
	@Override
	public String toString() {
		return new ToStringBuilder(this).append("文章审核日志", this.getOperatorStep()).toString();
	}

	/**
	 * 将DATE类型的时间格式化为字符串类型
	 *
	 * @return 字符串时间
	 */
	public String getOperatorTimeStr() {
		if (this.operatorTime != null) {
			this.operatorTimeStr = LocalDateUtil.showTime(this.operatorTime);
		}
		return this.operatorTimeStr;
	}

	public long getId() {
		return id;
	}

	public void setId(final long id) {
		this.id = id;
	}

	public long getLogicId() {
		return logicId;
	}

	public void setLogicId(final long logicId) {
		this.logicId = logicId;
	}

	public long getOrganLogicId() {
		return organLogicId;
	}

	public void setOrganLogicId(final long organLogicId) {
		this.organLogicId = organLogicId;
	}

	public long getArticleId() {
		return articleId;
	}

	public void setArticleId(final long articleId) {
		this.articleId = articleId;
	}

	public String getOperatorStep() {
		return operatorStep;
	}

	public void setOperatorStep(final String operatorStep) {
		this.operatorStep = operatorStep;
	}

	public long getOperatorId() {
		return operatorId;
	}

	public void setOperatorId(final long operatorId) {
		this.operatorId = operatorId;
	}

	public String getOperatorName() {
		return operatorName;
	}

	public void setOperatorName(final String operatorName) {
		this.operatorName = operatorName;
	}

	public LocalDateTime getOperatorTime() {
		return operatorTime;
	}

	public void setOperatorTime(final LocalDateTime operatorTime) {
		this.operatorTime = operatorTime;
	}

	public String getOperatorContent() {
		return operatorContent;
	}

	public void setOperatorContent(final String operatorContent) {
		this.operatorContent = operatorContent;
	}

	public String getExt1() {
		return ext1;
	}

	public void setExt1(final String ext1) {
		this.ext1 = ext1;
	}

	public String getExt2() {
		return ext2;
	}

	public void setExt2(final String ext2) {
		this.ext2 = ext2;
	}

	public String getExt3() {
		return ext3;
	}

	public void setExt3(final String ext3) {
		this.ext3 = ext3;
	}

	public String getExt4() {
		return ext4;
	}

	public void setExt4(final String ext4) {
		this.ext4 = ext4;
	}

	public String getExt5() {
		return ext5;
	}

	public void setExt5(final String ext5) {
		this.ext5 = ext5;
	}

	public String getOrganCode() {
		return organCode;
	}

	public void setOrganCode(final String organCode) {
		this.organCode = organCode;
	}

	public void setOperatorTimeStr(final String operatorTimeStr) {
		this.operatorTimeStr = operatorTimeStr;
	}

}